package com.leoandroid.tool.toolsbox.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.leoandroid.tool.toolsbox.bean.NBAInfoBean
import com.leoandroid.tool.toolsbox.largeread.R
import com.leoandroid.tool.toolsbox.largeread.databinding.ItemNbaParentLayoutBinding

class NBAMessageAdapter(val context:Context,val dataList:ArrayList<NBAInfoBean>) :RecyclerView.Adapter<NBAMessageAdapter.Holder>() {

    inner class Holder(itemView: View) :RecyclerView.ViewHolder(itemView){

    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val inflate = DataBindingUtil.inflate<ItemNbaParentLayoutBinding>(
            LayoutInflater.from(context),
            R.layout.item_nba_parent_layout,
            parent,
            false
        )
        return Holder(inflate.root)
    }

    override fun onBindViewHolder(holder: Holder, position: Int) {
         val dataBind: ItemNbaParentLayoutBinding? = DataBindingUtil.getBinding<ItemNbaParentLayoutBinding>(holder.itemView)
        dataBind?.apply {
            dataList[position].apply {
                weekTitle.text = "$date:$week"
                val adapter:NBAItemAdapter = NBAItemAdapter(context,list)
                nmaItemList.layoutManager = LinearLayoutManager(context)
                nmaItemList.adapter = adapter
            }
        }


    }

    override fun getItemCount(): Int {
        return dataList.size
    }
}